+
    function redirect(url){
    let main = window.location.host;
    if(!main.includes("http://")) main = "http://" + main
    window.location.assign(main + url);
}
function submit(url, data) {
    $.ajax({
        type : 'post',
        url : url,
        data : {'data':data},
        dataType: "json",
        success : function(response) {
            if(response.code <= 0) {
                layer.msg(response.messages,{icon:2,time:1000});
            } else{
                layer.msg(response.messages,{icon:1,time:1000});
                if(response.redirect != null)
                    redirect(response.redirect);
                else{
                    if(response.result != null)
                        setList(response,url);
                }
            }
        },
        error : function(response) {
            layer.msg('出错了捏~',{icon:2,time:500});
        }
    });
};

function submitModify(url, data) {
    $.ajax({
        type : 'post',
        url : url,
        data : {'data':data},
        dataType: "json",
        success : function(response) {
            if(response.code <= 0){
                layer.msg(response.messages,{icon:2,time:1000});
            } else{
                layer.msg(response.messages,{icon:1,time:1000});
                if(!url.includes("addFeedback")){
                    xadmin.father_reload();
                    xadmin.close();
                }
            }
        },
        error : function(response) {
            layer.msg('出错了捏~',{icon:2,time:500});
        }
    });
};

function setList(response,url){
    if(response.findType == 1){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].uId + "</td>\n" +
                "                                  <td>"+ list[i].uName + "</td>\n" +
                "                                  <td>"+ list[i].uUserName + "</td>\n" +
                "                                  <td>"+ list[i].uPassword + "</td>\n" +
                "                                  <td>"+ list[i].uGender + "</td>\n" +
                "                                  <td>"+ (list[i].uBirthdate == null ? '无':list[i].uBirthdate.toString().substring(0,list[i].uBirthdate.toString().lastIndexOf(" ")))  + "</td>\n" +
                "                                  <td>"+ list[i].uPhone + "</td>\n" +
                "                                  <td>"+ list[i].uEmail + "</td>\n" +
                "                                  <td>"+ list[i].uIdCard + "</td>\n" +
                "                                  <td>"+ list[i].uAddress + "</td>\n" +
                "                                  <td>"+ (list[i].uStatus > 0 ? '在住':'离开') + "</td>\n" +
                "                                  <td>"+ (list[i].uLiveTime == null ? '无':list[i].uLiveTime.toString().substring(0,list[i].uLiveTime.toString().lastIndexOf(" ")))  + "</td>\n" +
                "                                  <td>"+ list[i].uNotes + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    }else if(response.findType == 2){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].sId + "</td>\n" +
                "                                  <td>"+ list[i].sName + "</td>\n" +
                "                                  <td>"+ list[i].sUsername + "</td>\n" +
                "                                  <td>"+ list[i].sPassword + "</td>\n" +
                "                                  <td>"+ list[i].sGender + "</td>\n" +
                "                                  <td>"+ (list[i].sBirthdate == null ? '无':list[i].sBirthdate.toString().substring(0,list[i].sBirthdate.toString().lastIndexOf(" ")))  + "</td>\n" +
                "                                  <td>"+ list[i].sPhone + "</td>\n" +
                "                                  <td>"+ list[i].sEmail + "</td>\n" +
                "                                  <td>"+ list[i].sIdCard + "</td>\n" +
                "                                  <td>"+ list[i].sPosition + "</td>\n" +
                "                                  <td>"+ list[i].sAddress + "</td>\n" +
                "                                  <td>"+ list[i].sDepartment + "</td>\n" +
                "                                  <td>"+ (list[i].sEntryDate == null ? '无':list[i].sEntryDate.toString().substring(0,list[i].sEntryDate.toString().lastIndexOf(" ")))  + "</td>\n" +
                "                                  <td>"+ list[i].sSalary + "</td>\n" +
                "                                  <td>"+ (list[i].sStatus > 1 ? '请假/离职':'正常出勤') + "</td>\n" +
                "                                  <td>"+ list[i].sNotes + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    }else if(response.findType == 3){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].aId + "</td>\n" +
                "                                  <td>"+ list[i].aName + "</td>\n" +
                "                                  <td>"+ list[i].aUserName + "</td>\n" +
                "                                  <td>"+ list[i].aPassword + "</td>\n" +
                "                                  <td>"+ list[i].aGender + "</td>\n" +
                "                                  <td>"+ (list[i].aBirthdate == null ? '无':list[i].aBirthdate.toString().substring(0,list[i].aBirthdate.toString().lastIndexOf(" ")).trim()) + "</td>\n" +
                "                                  <td>"+ list[i].aPhone + "</td>\n" +
                "                                  <td>"+ list[i].aEmail + "</td>\n" +
                "                                  <td>"+ list[i].aIdCard + "</td>\n" +
                "                                  <td>"+ list[i].aPermission + "</td>\n" +
                "                                  <td>"+ (list[i].aEntryDate == null ? '无':list[i].aEntryDate.toString().substring(0,list[i].aEntryDate.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    }else if(response.findType == 4) {
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var status;
            if(list[i].fbStatus == 1) status = '已提交'
            else if(list[i].fbStatus == 2) status = '已受理'
            else if(list[i].fbStatus == 3) status = '已完成'
            else if(list[i].fbStatus == 4) status = '已关闭'
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].fbId + "</td>\n" +
                "                                  <td>"+ (list[i].fbSubmitDate == null ? '无':list[i].fbSubmitDate.toString().substring(0,list[i].fbSubmitDate.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                "                                  <td>"+ (list[i].fbType > 1 ? '物业服务':(list[i].fbType > 0 ? '维修设施':'投诉与建议')) + "</td>\n" +
                "                                  <td>"+ list[i].fbIssue + "</td>\n" +
                "                                  <td>"+ status + "</td>\n" +
                "                                  <td>"+ list[i].fbNotes + "</td>\n" +
                "                                  <td>"+ list[i].fbUserId + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    } else if(response.findType == 5){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].fdStaffId + "</td>\n" +
                "                                  <td>"+ list[i].fdFeedbackId + "</td>\n" +
                "                                  <td>"+ (list[i].fdDisposeTime == null ? '无':list[i].fdDisposeTime.toString().substring(0,list[i].fdDisposeTime.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                "                                  <td>"+ (list[i].fdStatus == 0 ? '未在处理':(list[i].fdStatus == 1 ? '仍在处理':'处理完成')) + "</td>\n" +
                "                                  <td>"+ list[i].fdNotes + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    } else if(response.findType == 6){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var status;
            if(list[i].fStatus == 0) status = '未支付'
            else if(list[i].fStatus == 1) status = '未收入'
            else if(list[i].fStatus == 2) status = '收入'
            else if(list[i].fStatus == 3) status = '支出'
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].fId + "</td>\n" +
                "                                  <td>"+ (list[i].fDate == null ? '无':list[i].fDate.toString().substring(0,list[i].fDate.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                "                                  <td>"+ list[i].fType + "</td>\n" +
                "                                  <td>"+ list[i].fAmount + "</td>\n" +
                "                                  <td>"+ list[i].fStakeholder + "</td>\n" +
                "                                  <td>"+ list[i].fNumber + "</td>\n" +
                "                                  <td>"+ status + "</td>\n" +
                "                                  <td>"+ list[i].fNotes + "</td>\n" +
                "                                  <td>"+ list[i].fStaffId + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    } else if(response.findType == 7){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var status;
            if(list[i].iStatus == 0) status = '未安装'
            else if(list[i].iStatus == 1) status = '正在使用'
            else if(list[i].iStatus == 2) status = '正在维修'
            else if(list[i].iStatus == 3) status = '已停用'
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].iId + "</td>\n" +
                "                                  <td>"+ list[i].iName + "</td>\n" +
                "                                  <td>"+ list[i].iType + "</td>\n" +
                "                                  <td>"+ list[i].iPrice + "</td>\n" +
                "                                  <td>"+ (list[i].iInstallDate == null ? '无':list[i].iInstallDate.toString().substring(0,list[i].iInstallDate.toString().lastIndexOf(" ")).trim()) + "</td>\n" +
                "                                  <td>"+ list[i].iLocation + "</td>\n" +
                "                                  <td>"+ list[i].iOverhaulTime + "</td>\n" +
                "                                  <td>"+ status + "</td>\n" +
                "                                  <td>"+ list[i].iStaffId + "</td>\n" +
                "                                  <td>"+ list[i].iFinanceId + "</td>\n" +
                "                                  <td>"+ list[i].iNotes + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    } else if(response.findType == 8){
        var list = response.result;
        var pathname = window.location.pathname;
        if(pathname.includes("/notice-query.html")){
            var nt=$(".layui-timeline")
            $(".layui-timeline").find('.list').remove();
            for (let i = 0; i < list.length; i++) {
                var notice=$("<li class=\"layui-timeline-item\">\n"+
                    "<i class=\"layui-icon layui-timeline-axis\"></i>\n" +
                    "                <div class=\"layui-timeline-content layui-text\">\n" +
                    "                    <h3 class=\"layui-timeline-title\">"+ (list[i].nPublishDate == null ? '无':list[i].nPublishDate.toString().substring(0,list[i].nPublishDate.toString().lastIndexOf(" ")).trim())  + "</h3>\n" +
                    "                    <p class='h4' style='color: rgb(0,150,136)'>"+list[i].nTitle +"</p>\n" +
                    "                    <p class='h6'>\n" + list[i].nContent  +
                    "                    </p>\n" +
                    "                </div>\n" +
                    "</li>")
                if(list[i].nStatus == 2)
                    nt.append(notice);
            }
            laydate.render()
        }else {
            var parent = $(".data-list")
            parent.find("tbody").remove();
            for (let i = 0; i < list.length; i++) {
                var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                    "                                  <td>\n" +
                    "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                    "                                  </td>\n" +
                    "                                  <td>"+ list[i].nId + "</td>\n" +
                    "                                  <td>"+ (list[i].nPublishDate == null ? '无':list[i].nPublishDate.toString().substring(0,list[i].nPublishDate.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                    "                                  <td>"+ list[i].nTitle + "</td>\n" +
                    "                                  <td style='white-space: nowrap;overflow: hidden;text-overflow:ellipsis'>"+ list[i].nContent + "</td>\n" +
                    "                                  <td>"+ list[i].nTarget + "</td>\n" +
                    "                                  <td>"+ list[i].nGrade + "</td>\n" +
                    "                                  <td>"+ (list[i].nStatus > 1 ? '已发布':'已关闭') + "</td>\n" +
                    "                                  <td>"+ list[i].nCategory + "</td>\n" +
                    "                                  <td>"+ list[i].nTag + "</td>\n" +
                    "                                  <td>"+ list[i].nAdminId + "</td>\n" +
                    "                                  <td class=\"td-manage\">\n" +
                    "                                      <a title=\"编辑\">\n" +
                    "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                    "                                      </a>\n" +
                    "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                    "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                    "                                    </a>\n" +
                    "                                  </td>\n" +
                    "                                </tr>\n" +
                    "                              </tbody>")
                parent.append(tbody)
            }
        }

    } else if(response.findType == 9){
        var list = response.result;
        var parent = $(".data-list")
        parent.find("tbody").remove();
        for (let i = 0; i < list.length; i++) {
            var tbody = $("<tbody>\n <tr class=\"trbody\">\n" +
                "                                  <td>\n" +
                "                                    <input type=\"checkbox\" name=\"\"  lay-skin=\"primary\">\n" +
                "                                  </td>\n" +
                "                                  <td>"+ list[i].oStaffId + "</td>\n" +
                "                                  <td>"+ list[i].oInfraId + "</td>\n" +
                "                                  <td>"+ (list[i].oStartDate == null ? '无':list[i].oStartDate.toString().substring(0,list[i].oStartDate.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                "                                  <td>"+ (list[i].oEndDate == null ? '无':list[i].oEndDate.toString().substring(0,list[i].oEndDate.toString().lastIndexOf(" ")).trim())  + "</td>\n" +
                "                                  <td>"+ (list[i].oStatus > 0 ? '通过':'未通过') + "</td>\n" +
                "                                  <td>"+ list[i].oNotes + "</td>\n" +
                "                                  <td class=\"td-manage\">\n" +
                "                                      <a title=\"编辑\">\n" +
                "                                          <i class=\"layui-icon\" onclick=\"doAction(this.parentElement.parentElement.parentElement)\">&#xe642;</i>\n" +
                "                                      </a>\n" +
                "                                    <a title=\"删除\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                "                                      <i class=\"layui-icon\">&#xe640;</i>\n" +
                "                                    </a>\n" +
                "                                  </td>\n" +
                "                                </tr>\n" +
                "                              </tbody>")
            parent.append(tbody)
        }
    }
    layui.form.render();
}
